package io.aircraft.modules.api.service.impl;

import io.aircraft.common.constant.Constant;
import io.aircraft.common.utils.ProcResult;
import io.aircraft.modules.api.dao.ApiTaskDao;
import io.aircraft.modules.api.dto.NoticeByWcsDTO;
import io.aircraft.modules.api.entity.CallbackByWcsEntity;
import io.aircraft.modules.api.entity.NoticeByWcsEntity;
import io.aircraft.modules.api.service.ApiTaskService;
import io.aircraft.modules.wms.dto.CallbackRecordDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ApiTaskServiceImpl implements ApiTaskService {
    @Autowired
    private ApiTaskDao apiDao;

    /**
     * wcs系统上报任务完成情况
     *
     * @param dto
     * @return
     */
    @Override
    public ProcResult callbackByWcs(CallbackRecordDTO dto) {
        CallbackByWcsEntity parameter = new CallbackByWcsEntity();
        parameter.setRequestPk(dto.getRequestPk());
        parameter.setUserId(Constant.ClientCode.WCS.getId());
        apiDao.procCallbackByWcs(parameter);
        return new ProcResult().result(parameter.getCode(), parameter.getMsg());
    }

    /**
     * wcs系统上报放行通知
     *
     * @param dto
     * @return
     */
    @Override
    public ProcResult noticeByWcs(NoticeByWcsDTO dto) {
        NoticeByWcsEntity parameter = new NoticeByWcsEntity();
        parameter.setPosition(dto.getCurPos());
        parameter.setAmount(dto.getAmount());
        parameter.setUserId(Constant.ClientCode.WCS.getId());
        apiDao.procNoticeByWcs(parameter);
        return new ProcResult().result(parameter.getCode(), parameter.getMsg());
    }
}
